home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / UTIL / CD Playthrough 1.5.sit / CD Playthrough 1.5 / Source / main.c < prev    next >
C/C++ Source or Header  |  1994-10-03  |  2KB  |  89 lines

  1. //    CD Playthrough
  2. //    Version: 1.5 <October 3, 1994>
  3. //    (c)    1994 neg.active.productions, jwang@csua.berkeley.edu <James    Wang>  
  4. //    ftp://ftp.csua.berkeley.edu/pub/jwang/cool/cd-playthrough-15.hqx
  5.  
  6. //    File:            main.c
  7. //
  8. //    Contains:        C program to juggle sound input and output rate options
  9. //
  10. //    Written by:        James Wang
  11. //
  12. //    Description:    Includes main() dispatching routine, initialization and
  13. //                    miscellaneous utility routines.
  14.  
  15.  
  16. #include "main.h"
  17.  
  18.  
  19. void init_all(void)
  20. {
  21.     InitGraf((Ptr) &qd.thePort);
  22.     InitFonts();
  23.     InitWindows();
  24.     InitMenus();
  25.     FlushEvents(everyEvent, 0);
  26.     TEInit();
  27.     InitDialogs(0L);
  28.     InitCursor();
  29. }
  30.  
  31. void stop_alert(short id)
  32. {
  33.     Str255            errMessage;
  34.     Str15            numMessage;
  35.  
  36.     GetIndString(errMessage, kErrMessageID, id);
  37.     NumToString((long)id, numMessage);
  38.  
  39.     if (errMessage[0] == 0)
  40.         ParamText("¥pError message not found, program may be damaged!", numMessage, 0, 0);
  41.     else
  42.         ParamText(errMessage, numMessage, 0, 0);
  43.  
  44.     StopAlert(kStopAlertID, 0);
  45.     ExitToShell();
  46. }
  47.  
  48. void handle_res_error(short err)
  49. {
  50.     if (err != noErr)
  51.     {
  52.         if ( (err >= wrPermErr) && (err <= dirFulErr) )
  53.             stop_alert(DiskError);
  54.         if (err == memFullErr)
  55.             stop_alert(MemFull);
  56.         stop_alert(ResError);
  57.     }
  58. }
  59.  
  60. Boolean is_pressed(unsigned short k)
  61. {
  62.     unsigned char    km[16];
  63.  
  64.     GetKeys((long *)km);
  65.     return ((km[k>>3] >> (k & 7)) & 1);
  66. }
  67.  
  68. void main(void)
  69. {
  70.     SoundSetting    mySnd;
  71.  
  72.     init_all();
  73.  
  74.     if (is_pressed(kcCtrl)) {
  75.         get_sound_in(&mySnd);
  76.         get_sound_out(&mySnd);
  77.         save_prefs(&mySnd);
  78.         return;
  79.     }
  80.  
  81.     if (is_pressed(kcCmd))
  82.         system_prefs(&mySnd);
  83.     else
  84.         read_prefs(&mySnd);
  85.  
  86.     set_sound_in(&mySnd);
  87.     set_sound_out(&mySnd);
  88. }
  89.